#pragma once
#include "IwSound.h"

class AudioSystem;

class AudioStorage : public CIwManaged {
	public:
	IW_MANAGED_DECLARE( AudioStorage );
	
	void Serialise();
	
	void Save( AudioSystem *audio_system );
	void Load( AudioSystem *audio_system );
	
	float m_volume;
};

class AudioSystem
{

public:
	AudioSystem(){};
	~AudioSystem(){};
	
	void Load();
	void Unload();

	void Play(const char* ZeSoundName);

	void SetVolume(float Volumee)
	{
		if(Volumee>1.0f) Volumee = 1.0f;
		if(Volumee<0.0f) Volumee = 0.0f;
		Volume=iwsfixed(IW_FIXED(Volumee));
		
		if( MusicInstance != NULL ) {
			MusicInstance->SetVol(Volume);
		}
	}
	float GetVolume(){return IW_FIXED_TO_FLOAT(Volume);}
		
	void Update( float dt );
	void Render();

private:
	CIwResGroup *soundres_group;
	CIwSoundSpec* SoundSpec;
	CIwSoundInst* SoundInstance;
	CIwSoundInst* MusicInstance;
	iwsfixed Volume;
};
